/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package network;

import java.util.ArrayList;
import java.util.List;
import weibo4j.Timeline;
import weibo4j.Weibo;
import weibo4j.model.Paging;
import weibo4j.model.Status;
import weibo4j.model.WeiboException;

/**
 *
 * @author Administrator
 */
public class testSource {

    public static List<String> source = new ArrayList<String>();

    public static void main(String[] args) throws WeiboException {
        prepareWeibo();
        List<Status> status = getStatus();
        analyseStatus(status);
    }

    public static void analyseStatus(List<Status> status) {
        for (Status s : status) {
            String r = s.getSource().getName();
            String url = s.getSource().getUrl();
            String txt=s.getText();

            String un=s.getUser().getName();
            if (source.contains(r)) {
                continue;
            } else {
                source.add(r);
                System.out.println(r+" "+un+" "+url+" "+txt);

                
            }
        }
    }

    public static List<Status> getStatus() throws WeiboException {
        List<Status> status = new ArrayList<Status>();
        String username = Config.username;
        String uid = Config.uid;
        Timeline tm = new Timeline();
        for (int i = 1; i < 100; i++) {
            System.out.println("Page "+i);
            List<Status> tmp = tm.getHomeTimeline(0,0,new Paging(i,200));
            if (!tmp.isEmpty()) {
                status.addAll(tmp);
            } else {
                break;
            }
        }
        return status;
    }

    public static void prepareWeibo() {
        String access = Auth.Auth4Code.getCode();
        Weibo weibo = new Weibo();
        weibo.setToken(access);
    }
}
